<template>
	<view class="page">
		<view class="code-get">
			<view class="code">
				<input type="password"  :placeholder="type==1?'请输入原登录密码':'请输入原支付密码'" v-model="yPassword">
			</view>
			<view class="code">
				<input type="password"  :placeholder="type==1?'请输入新登录密码':'请输入新支付密码'" v-model="Password">
			</view>
			<view class="code">
				<input type="password"  :placeholder="type==1?'请确认登录密码':'请确认支付密码'" v-model="xPassword">
			</view>
			<view class="btn" @click="tui.dianji(submite)">
				<text>确定</text>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isSetting: false,
				type:'',
				yPassword:'',
				Password:'',
				xPassword:''
			};
		},
		onLoad(e) {
			this.type=e.type
			uni.setNavigationBarTitle({
				title: e.type === '1' ? '修改登录密码':'修改支付密码'
			})
		},
		methods:{
			submite(){
				let that = this
				if(that.yPassword==''){
					that.tui.toast('请输入原登录密码')
					return
				}
				if(that.Password==''){
					that.tui.toast('请输入新登录密码')
					return
				}
				if(that.xPassword!=that.Password){
					that.tui.toast('两次密码不一致')
					return
				}
				that.tui.request(that.type==1?'api.auth.center/updateLoginPassword':"api.auth.center/payPassword", "POST", {login_password_y:that.yPassword,login_password:that.Password,pay_password:that.password}, false, false, true).then((res) => {
					that.tui.toast(res.info)
					if(res.code==1){
						if(that.type==1){
							uni.clearStorageSync()
							setTimeout(function(){
								uni.reLaunch({
									url:that.tui.loginUrl()+'#/pages/login/login?url='+that.tui.faceUrl()+"&inviter_code="+uni.getStorageSync('refCode')
								})
							},1000)
						}else{
							setTimeout(function(){
								uni.navigateBack()
							},1000)
						}
					}
				}).catch((res) => {
					
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	@import 'PaymentdlPassword.scss';
</style>
